package com.singzi.leetcode.N1100;
/**
 * 给定一个仅包含数字 2-9 的字符串，返回所有它能表示的字母组合。九键
 */

import java.util.ArrayList;
import java.util.List;

public class T1017Huishuo {
    public static void main(String[] args) {
        Solution mobile = new Solution();
        System.out.println(mobile.letterCombinations("583563"));
    }

}

class Solution {
    public List<String> letterCombinations(String digits) {
        if(digits == null || digits.length() == 0){
            return new ArrayList<>();
        }
        String str = "";
        traceBack(str,digits,0);
        return list;
    }
    String[] s = new String[]{"abc", "def","ghi","jkl","mno","pqrs","tuv","wxyz"};
    private final List <String>list = new ArrayList<>();
    private void traceBack(String temp,String digits,int index){
        if(index == digits.length()){
            list.add(temp);
            return;
        }
        for(Character c : s[Integer.parseInt(String.valueOf(digits.charAt(index)))-2].toCharArray()){
            traceBack(temp + c, digits, index + 1);
        }

    }
}